home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: Alpha / Whiteline Alpha.iso / tex / tools / dvi / stylus.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-22  |  4.2 KB  |  192 lines

  1. /*************************************************************************
  2. ****  Hier der speziell an den Stylus 800-Drucker von Epson angepaßte ****
  3. ****  24-Nadeltreiber. (Wie schön wäre es, wenn alle neuen Drucker    ****
  4. ****  HPCL könnten...)                                                ****
  5. *************************************************************************/
  6.  
  7. #include <portab.h>
  8.  
  9. #include "mintbind.h"
  10. #include "treiber.h"
  11.  
  12. /** Vorläufige Parameter */
  13. #define MAX_DPI    360L
  14. #define    WEITE    2880L
  15. #define HOEHE    -1L
  16. #define OBEN    0L
  17. #define LINKS    0L
  18.  
  19.  
  20. #ifdef FAST_PRN
  21. #define WRITE(i,j) ((th>0)?(Fwrite(th,i,j)):(print_block(i,j)))
  22. #endif
  23.  
  24.  
  25. /* Reset + NLQ + Einheit 1/MAX_DPI" + Zeilenabstand 48/MAX_DPI" */
  26. UBYTE    *INIT     = "  \033@\033x\001\033(U\001\000\012\033$\000\000\033(V\002\000\000\000";
  27. UBYTE    *H_STEP    = "\033$xx";
  28. UBYTE    *V_STEP    = "\033(v\002\000xx";
  29. UBYTE    *GRAFIK    = "\033*";
  30.  
  31.  
  32. struct
  33. {
  34.     UBYTE    modus;
  35.     WORD    h_dpi;
  36.     WORD    v_dpi;
  37.     WORD    t;
  38. } modus[13]=
  39. {
  40.     { 0, 60, 60, 1 },
  41.     { 4, 80, 60, 1 },
  42.     { 6, 90, 60, 1 },
  43.     { 1, 120, 60, 1 },    /*+*/
  44.     { 3, 240, 60, 1 },    /*+*/
  45.     { 32, 60, 180, 3 },
  46.     { 38, 90, 180, 3 },
  47.     { 33, 220, 180, 3 },
  48.     { 39, 180, 180, 3 },
  49.     { 40, 360, 180, 3 },    /*+*/
  50.     { 71, 180, 360, 6 },
  51.     { 73, 360, 360, 6 }
  52. };
  53. /*+* heißt: Kann keine nebeneinanderliegenden Punkte drucken! */
  54.  
  55. /* Zwischenspeicher für eine Zeile */
  56. static UBYTE    tmp[WEITE*6L+5L];
  57.  
  58.  
  59.  
  60. WORD    drucke( UBYTE *p, LONG weite, LONG max_zeile, LONG h_dpi, LONG v_dpi )
  61. {
  62.     extern char    tmp_file[256]; /* In Datei drucken? */
  63.     extern long    max_puffer_laenge;
  64.  
  65.     LONG    max_spalte, zeile, lz, links, linker_rand, rechts;
  66.     LONG    len, i, d_modus, bits_per_row;
  67.     WORD    th=0;
  68.  
  69. #ifdef FAST_PRN
  70.     /* Für viel Geschwindigkeit = sinnvoll großer Puffer */
  71.     max_puffer_laenge = WEITE*6L+256L;
  72.     if(  tmp_file[0]>0  ||  open_printer()<0  )
  73. #endif
  74.         th = (WORD)get_tempfile( "sls" );
  75.     if(  th<0  )
  76.         return -1;
  77.  
  78.     if(  v_dpi<200    )
  79.     {
  80.         if(  v_dpi<80  )
  81.             v_dpi = 60;
  82.         else
  83.             v_dpi = 180;
  84.     }
  85.     else
  86.         v_dpi = MAX_DPI;
  87.  
  88.     for(  d_modus=0;  d_modus<12;  d_modus++  )
  89.         if(  (h_dpi*90)/100<modus[d_modus].h_dpi  &&  v_dpi==modus[d_modus].v_dpi  )
  90.             break;
  91.     h_dpi = modus[d_modus].h_dpi;
  92.     bits_per_row = 8*modus[d_modus].t;
  93.     d_modus = modus[d_modus].modus;
  94.  
  95.         /* Ab hier wird es ernst */
  96.     if(  weite<(WEITE*h_dpi)/360L  )
  97.         max_spalte = (weite+7)/8;
  98.     else
  99.         max_spalte = (WEITE*h_dpi)/(MAX_DPI*8L);
  100.  
  101.         /* Diverse Variablen initialisieren */
  102.     zeile = 0;
  103.     weite = (weite+15L)/16L;
  104.     weite *= 2;
  105.     p += weite*OBEN + LINKS;    /* Nicht druckbare Ränder*/
  106.     max_zeile -= OBEN;
  107.     if(  HOEHE>0    &&    (max_zeile*v_dpi)/MAX_DPI>HOEHE  )
  108.         max_zeile = HOEHE;
  109.  
  110.     for(  linker_rand=0;    ist_next_leer( p+linker_rand, weite, max_zeile )  &&  linker_rand<max_spalte;  linker_rand++  )
  111.         ;
  112.     if(  linker_rand==max_spalte  )
  113.     {    /* Leerseite */
  114.         WRITE( 1L, "\014" );
  115.         return th;
  116.     }
  117.  
  118.         /* Reset + LQ-Mode */
  119.     WRITE( 24L, INIT );
  120.  
  121.     /* Endlich drucken */
  122.     lz = 0;
  123.     max_zeile--;
  124.     while(    zeile<max_zeile )
  125.     {
  126.         /* Leerzeilen überspringen */
  127.         while(  zeile<max_zeile  &&  ist_leerzeile( p, max_spalte )  )
  128.         {
  129.             lz++;
  130.             zeile++;
  131.             p += weite;
  132.         }
  133.  
  134.         if(  zeile>=max_zeile  )
  135.         {
  136.             lz = lz+(max_zeile-zeile)-bits_per_row;
  137.             if(  lz>0  )
  138.                 break;
  139.         }
  140.  
  141.         if(     lz!=0  )
  142.         {    /* Leerzeilen überspringen */
  143.             i = (lz*MAX_DPI)/v_dpi;
  144.             V_STEP[5] = (UBYTE)i;
  145.             V_STEP[6] = (UBYTE)(i>>8);
  146.             WRITE( 7L, V_STEP );
  147.         }
  148.  
  149.             /* Ränder feststellen */
  150.         for(    rechts=max_spalte-1;    ist_next_leer( p+rechts, weite, bits_per_row )    &&    rechts>linker_rand;  rechts--  )
  151.             ;
  152.         rechts++;
  153.         for(  links=linker_rand;    ist_next_leer( p+links, weite, bits_per_row )    &&    links<rechts;  links++  )
  154.             ;
  155.         if(    links>0    )
  156.         {    /* Linker Rand */
  157.             i = (links*8L*MAX_DPI)/h_dpi;
  158.             H_STEP[2] = (UBYTE)i;
  159.             H_STEP[3] = (UBYTE)(i>>8);
  160.             WRITE( 4L, H_STEP );
  161.         }
  162.  
  163.         len = rechts-links;
  164.         tmp[0] = '\033';
  165.         tmp[1] = '*';
  166.         tmp[2] = (UBYTE)d_modus;
  167.         tmp[3] = (UBYTE)((len%32)*8);
  168.         tmp[4] = (UBYTE)(len>>5);
  169.  
  170.         block_it( tmp+5, p+links, len, weite, bits_per_row/8 );
  171.         WRITE( 5L+len*bits_per_row, tmp );
  172.         p += weite*bits_per_row;
  173.         zeile += bits_per_row;
  174.         lz = bits_per_row;
  175.  }
  176.  
  177.         /* Ende Seite */
  178.     if(  1!=WRITE( 1L, "\014" )  )
  179.     {
  180.         /* Platz reichte nicht aus */
  181.         if(  th>0  )
  182.             Fclose( th );
  183.         th = -1;
  184.     }
  185.  
  186.     if(  tmp_file[0]==0  )
  187.         flush_block();
  188.     return th;
  189. }
  190. /* 17.8.93 */
  191.  
  192.